package com.h3c.nem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.h3c.nem.entity.TbWorkerExperience;
import org.apache.ibatis.annotations.Insert;

/**
 * 数据库访问层
 *
 * @author chenyifan
 * @since 2022-06-06 15:46:12
 */
public interface TbWorkerExperienceMapper extends BaseMapper<TbWorkerExperience> {

    @Insert("INSERT INTO tb_worker_experience \n" +
            "(experience_id, worker_id, offer_id , work_place, begin_date, \n" +
            "end_date, department, post, type, leave_reason, reference_name, reference_name_contact, \n" +
            "update_time, already_save, experience_type, is_beisen_data) \n" +
            "SELECT \n" +
            "nextval('hrssseq'), a.HC_NO, b.OfferID, b.WorkPlace, \n" +
            "CASE WHEN b.BeginDate = '' THEN NULL WHEN length(b.BeginDate) != 10 THEN NULL ELSE STR_TO_DATE(b.BeginDate,'%Y-%m-%d') END, \n" +
            "CASE WHEN b.EndDate = '' THEN NULL WHEN length(b.EndDate) != 10 THEN NULL ELSE STR_TO_DATE(b.EndDate,'%Y-%m-%d') END, \n" +
            "b.Department, b.Post, b.Type, b.ReasonOfLeave, b.ReferenceName, b.ReferenceNameContact, NOW(), 0, 1, 1 \n" +
            "FROM Offer_Send_Detail a, Offer_WorkInfo b \n" +
            "WHERE a.id= b.OfferID" )
    void initExperienceRecordFromHrss();
}

